home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC02BusyBox / BusyBox.asm / UWindow.asm < prev   
Encoding:
Assembly Source File  |  1990-05-25  |  7.6 KB  |  264 lines  |  [04] ASCII Text (0x0000)

  1. ***********************************************************************
  2. *
  3. * busybox uwindow.asm -- Version 3.0 
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * This file contains the code which implements windows in
  12. * the busybox program.
  13. *
  14. ***********************************************************************
  15.  
  16.                case on
  17.  
  18.                copy 2/ainclude/e16.resources
  19.                copy busybox.equ
  20.  
  21.                mcopy macros/uwindow.macros
  22.  
  23.                longi on
  24.                longa on
  25.  
  26. MainWindowID        gequ $2000
  27.  
  28. ************************************************************************
  29. *
  30. * drawThisWindow
  31. *
  32. * This routine draws the contents of all the windows.
  33. *
  34. drawThisWindow start
  35.  
  36.                phb                      ;This is not needed now.  This function
  37.                phk                      ;may get more complicated for developers,
  38.                plb                      ;and may include references to global data,
  39. *                                       ;at which time this would be necessary.
  40.                pha
  41.                pha
  42.                _GetPort
  43.                _DrawControls
  44.  
  45.                plb                      ;Restore dataBank.
  46.                rtl
  47.  
  48.                end
  49.  
  50. ************************************************************************
  51. *
  52. * doCloseTop
  53. *
  54. * This routine closes the topmost window.  We do a little work to
  55. * prevent the main window from being closed.
  56. *
  57. doCloseTop     start
  58.  
  59.                DefineStack
  60.  
  61. tempWin        long
  62.  
  63. saveDPage      word
  64. returnAddr     word
  65.  
  66. ******************
  67.  
  68.                phd                      ;Save directPage register.
  69.                pha                      ;Make space for tempWin.
  70.                pha
  71.                tsc                      ;Set directPage register.
  72.                tcd
  73.  
  74.                pha                      ;Who's on top?
  75.                pha
  76.                _FrontWindow
  77.                PullLong tempWin
  78.  
  79.                ldy #1|2                 ;Find the window entry.  We start at 1
  80. loop           lda windowList,y         ;since we never close the top window.
  81.                cmp tempWin              ;When we find it, we close it and zero
  82.                bne next                 ;the entry.
  83.                lda windowList+2,y
  84.                cmp tempWin+2
  85.                beq gotit
  86. next           iny
  87.                iny
  88.                iny
  89.                iny
  90.                cpy #NumWindows|2
  91.                bcc loop
  92.                bra notOurs              ;It isn't one of ours.
  93.  
  94. gotit          lda #0
  95.                sta windowList,y
  96.                sta windowList+2,y
  97.                pei tempWin+2
  98.                pei tempWin
  99.                _CloseWindow
  100.                bra allDone
  101.  
  102. notOurs        pha                      ;Find out what kind of window.
  103.                pei tempWin+2
  104.                pei tempWin
  105.                _GetSysWFlag
  106.                pla                      ;Well, what's it going to be?
  107.                beq allDone              ;Don't close that last window of ours.
  108.                pei tempWin+2
  109.                pei tempWin
  110.                _CloseNDAByWinPtr
  111.  
  112. allDone        pla                      ;Remove space for tempWin.
  113.                pla
  114.                pld                      ;Restore directPage register.
  115.                rts
  116.  
  117.                end
  118.  
  119. ******************************************************************************
  120. *
  121. * openThisWindow
  122. *
  123. * This routine either opens the specified window or brings it to the top
  124. * if it is already open.
  125. *
  126. * If it is not open, we open it with NewWindow2 invisibly, adjust the window's
  127. * location and then show and select the window.
  128. *
  129. openThisWindow start
  130.  
  131.                DefineStack
  132.  
  133. wptr           long
  134.  
  135. saveDPage      word
  136. returnAddr     word
  137.  
  138. ctlid          word
  139.  
  140. ******************
  141.  
  142.                phd                      ;Save directPage register.
  143.                pha                      ;Make space for wptr.
  144.                pha
  145.                tsc
  146.                tcd                      ;Set directPage register.
  147.  
  148.                lda ctlid
  149.                asl a
  150.                asl a
  151.                tay
  152.                lda windowList,y
  153.                sta wptr
  154.                lda windowList+2,y
  155.                sta wptr+2
  156.  
  157.                ora wptr                 ;Hi-word in acc.
  158.                bne justSelect           ;Window already open.
  159.  
  160.                pha                      ;Result space
  161.                pha
  162.                pea 0|-16                ;NULL
  163.                pea 0
  164.                pea 0|-16                ;NULL
  165.                pea 0
  166.                pea drawThisWindow|-16   ;Update procedure
  167.                pea drawThisWindow
  168.                pea 0|-16                ;NULL
  169.                pea 0
  170.                pea 2                    ;What type.
  171.                pea 0|-16                ;Hi-word of below ctlid.
  172.                lda ctlid
  173.                clc
  174.                adc #MainWindowID
  175.                pha
  176.                pea rWindParam1
  177.                _NewWindow2
  178.                lda ctlid
  179.                asl a
  180.                asl a
  181.                tay
  182.                pla
  183.                sta wptr                 ;Store window pointer in list.
  184.                sta windowList,y
  185.                pla
  186.                sta wptr+2
  187.                sta windowList+2,y
  188.  
  189.                lda ctlid
  190.                cmp #Prog1ID
  191.                bcs noMove
  192.                lda staggerCount
  193.                asl a
  194.                asl a
  195.                asl a
  196.                adc #50
  197.                pha                      ;New xloc.
  198.                pha                      ;New yloc.
  199.                pei wptr+2
  200.                pei wptr
  201.                _MoveWindow
  202.                lda staggerCount
  203.                inc a
  204.                cmp #7                   ;Up to 7 windows to stagger.
  205.                bcc aa
  206.                sbc #7
  207. aa             sta staggerCount
  208.  
  209. noMove         pei wptr+2               ;Window opened as invisible so
  210.                pei wptr                 ;that it could be moved without
  211.                _ShowWindow              ;affecting up the screen.
  212.  
  213. justSelect     pei wptr+2               ;Make sure window is on top.
  214.                pei wptr
  215.                _SelectWindow
  216.  
  217.                pla                      ;Remove space for wptr.
  218.                pla
  219.                pld                      ;Restore directPage register.
  220.                plx                      ;Keep return address.
  221.                pla                      ;Remove passed parameter.
  222.                phx                      ;Put return address back
  223.                rts                      ;  and return.
  224.  
  225.                end
  226.  
  227. *******************************************************************************
  228. *
  229. * setupWindows
  230. *
  231. * Sets up windowList record for use through out the program.
  232. *
  233. setupWindows   start
  234.  
  235.                ldy #NumWindows|2-2
  236.                lda #0
  237. loop           sta windowList,y
  238.                dey
  239.                dey
  240.                bne loop                 ;Element 0 will be set below.
  241.  
  242.                pha                      ;Result space
  243.                pha
  244.                pea 0|-16                ;NULL
  245.                pea 0
  246.                pea 0|-16                ;NULL
  247.                pea 0
  248.                pea drawThisWindow|-16   ;Update procedure
  249.                pea drawThisWindow
  250.                pea 0|-16                ;NULL
  251.                pea 0
  252.                pea 2                    ;What type.
  253.                pea MainWindowID|-16
  254.                pea MainWindowID
  255.                pea rWindParam1
  256.                _NewWindow2
  257.                pla
  258.                sta windowList
  259.                pla
  260.                sta windowList+2
  261.                rts
  262.  
  263.                end
  264.